<?php
/* -------------------------------------------
 * HTTP Request object, design based on Zend_Constroller_Request_Http
 * 
 * Passing it a context but not currently using it
 * Perhaps might want it for logging
 */
class Cerad_Request
{
	protected $context = NULL;
	
	function __construct($context)
	{
		$this->context = $context;
	}
	public function getQuery($key = null, $default = null) 
    { 
        if (null === $key) {
            return $_GET;
        }

        return (isset($_GET[$key])) ? $_GET[$key] : $default; 
    }
    public function getPost($key = null, $default = null) 
    { 
        if (null === $key) {
            return $_POST;
        }

        return (isset($_POST[$key])) ? $_POST[$key] : $default; 
    }
    public function getCookie($key = null, $default = null) 
    { 
        if (null === $key) {
            return $_COOKIE;
        }

        return (isset($_COOKIE[$key])) ? $_COOKIE[$key] : $default; 
    } 
    public function getServer($key = null, $default = null) 
    { 
        if (null === $key) {
            return $_SERVER;
        }

        return (isset($_SERVER[$key])) ? $_SERVER[$key] : $default; 
    } 
    public function getEnv($key = null, $default = null) 
    { 
        if (null === $key) {
            return $_ENV;
        }

        return (isset($_ENV[$key])) ? $_ENV[$key] : $default; 
    }
	public function getMethod()
    {
        return $this->getServer('REQUEST_METHOD');
    }
    public function isPost()
    {
        if ('POST' == $this->getMethod()) {
            return true;
        }
        return false;
    }
    public function isQuery()
    {
        if ('GET' == $this->getMethod()) {
            return true;
        }
        return false;
    }
}
?>